/*
 * Copyright 2007-2009 Thomas Krause (thomas@berlin-reloaded.de)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.gidoo.websites.example.plugins;

import java.io.Serializable;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.Model;
import org.gidoo.cms.IEditPlugin;

/**
 *
 * @author <a href="mailto:thomas@berlin-reloaded.de">Thomas Krause</a>
 */
public class TestEditingPlugin implements IEditPlugin, Serializable
{

  String currentSelectedPage = null;
  MyPanel p;
  
  public void setCurrentSelectedPage(Node currentSelectedPage)
  {
    try
    {
      this.currentSelectedPage = currentSelectedPage == null ? null 
        : currentSelectedPage.getPath();
    }
    catch(RepositoryException ex)
    {
      Logger.getLogger(TestEditingPlugin.class.getName()).log(Level.SEVERE, null, ex);
    }
  }

  public String getPluginName()
  {
    return "Example";
  }

  public Panel getPluginPanel(String id)
  {
    return new MyPanel(id, currentSelectedPage);
  }

  public class MyPanel extends Panel
  {
    public MyPanel(String id, String pathToNode)
    {
      super(id);
      add(new Label("lblPath", new Model(pathToNode != null ? pathToNode : "null")));
    }
  }
  
}
